<?php


namespace app\admin\validate;


use think\Validate;

/**
 * Class Article
 * @package app\admin\validate
 * @author Mr.Liu Wuchen
 * @create 2021-06-23 15:34
 */
class Article extends Validate
{

    /**
     * 验证规则
     * @var string[]
     */
    protected $rule = [
        'article_id'  => 'require|number|gt:0',
        'category_id' => 'require',
        'title'       => 'require|unique:admin_article|max:30',
        'author'      => 'max:15',
        'desc'        => 'max:120',
        'content'     => 'require',
    ];

    /**
     * 错误信息
     * @var string[]
     */
    protected $message = [
        'article_id.require'  => '参数错误',
        'article_id.number'   => '参数错误',
        'article_id.gt'       => '参数错误',
        'category_id.require' => '请选择分类',
        'title.require'       => '请填写标题',
        'title.unique'        => '标题已经存在',
        'title.max'           => '标题最多30个字符',
        'author.max'          => '作者最多15个字符',
        'desc.max'            => '简介最多120个字符',
        'content.require'     => '请填写文章内容',
    ];

    /**
     * 验证场景
     * @var string[]
     */
    protected $scene = [
        'create' => ['category_id', 'author', 'title', 'desc', 'content'],
        'update' => ['category_id', 'author', 'title', 'desc', 'content', 'article_id'],
    ];

}